package com.example.demo.api.Controller;

import com.example.demo.api.Dto.EmployeeDto;
import com.example.demo.domain.entity.Employee;
import com.example.demo.service.EmployeeService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/v1/employee")
public class EmployeeController {
    private final EmployeeService employeeService;

    public EmployeeController(EmployeeService employeeService) {
        this.employeeService = employeeService;
    }

    @GetMapping("/list")
    public ResponseEntity<?> list(EmployeeDto employeeDto) {
        List<Employee> employeeList = employeeService.listEmployees(employeeDto);
        return ResponseEntity.ok(employeeList);
    }

    @GetMapping("/employeeId")
    public ResponseEntity<?> list(@PathVariable("employeeId") Integer employeeId) {
        Employee employee = employeeService.findEmployeeById(employeeId);
        return ResponseEntity.ok(employee);
    }

    @GetMapping("/get-employee-with-leader")
    public ResponseEntity<?> getEmployeeWithLeader(EmployeeDto employeeDto) {
        Employee employee = employeeService.getEmployeeWithLeader(employeeDto);
        return ResponseEntity.ok(employee);
    }

    @GetMapping("/get-employee-list")
    public ResponseEntity<?> getEmployeeList(EmployeeDto employeeDto) {
        List<Employee> employee = employeeService.getEmployeeList(employeeDto);
        return ResponseEntity.ok(employee);
    }
}
